

import java.util.ArrayList;
import Server.Proxy;
import fit.ActionFixture;

public class CheckLogIn extends ActionFixture {

	Proxy func;
	String userID;
	String password;
	
	public void connection() {
		func = new Proxy("jdbc:mysql://localhost/obl2", "root","");
	}
	public void setID(String id) {
		this.userID=id;
	}
	public void setPassword(String password) {
		this.password=password;
	}


	public boolean canLogIn() {
		boolean match;
		ArrayList<String> ref = new ArrayList<String>();
		ArrayList<String> result = new ArrayList<String>();
		ref.add("update_useronline");
		ref.add(userID);
		match=func.chkUser(userID, password);
		if (match==true)
		{
			result=func.checkonline(ref);
			if (result.get(0).equalsIgnoreCase("1"))
				return false;
			else
			{
				ref.add("1");
				func.update_useronline(ref);
				return true;
			}
				
		}
		return false;
		
	}
	
	
	
	

}

